package com.tencent.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tencent.entity.Pagination;
import com.tencent.entity.SetMeal;
import com.tencent.mapper.SetMealMapper;
import com.tencent.service.SelMealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SelMealServiceImpl implements SelMealService {
    @Autowired
    private SetMealMapper setMealMapper;

    @Override
    public int add(SetMeal setMeal) {
        int add = setMealMapper.add(setMeal);
        return add;
    }

    @Override
    public List<SetMeal> findAll() {

        return setMealMapper.findAll();
    }

    @Override
    public int deleteByCode(String code) {
        int i = setMealMapper.deleteByCode(code);
        return i;
    }

    @Override
    public PageInfo<SetMeal> findByCode(Pagination pagination) {
        PageHelper.startPage(pagination.getCurrentPage(),pagination.getPageSize());
        List<SetMeal> byCode = setMealMapper.findByCode(pagination.getQueryString());
        return  new PageInfo<>(byCode);
    }

    @Override
    public int updateSetmeal(SetMeal setMeal) {
        return setMealMapper.updateSetmeal(setMeal);
    }


}
